
from selenium import webdriver
import time

from selenium.webdriver.common.by import By


# 2. 注册操作
class Ecshop:
    # 初始化实例对象
    def __init__(self):
       self.driver =webdriver.Chrome()


    def search(self):
        #找到首页网址
        self.driver.get('https://ecshop.test2.shopex123.com/')
        # 通过class定位免费组成页面
        self.driver.find_element(By.CLASS_NAME ,"reg").click()

    def register(self):
        #通过id定位用户名输入框.输入用户名
        self.driver.find_element(By.ID,"username").send_keys('KKSD')
        # 通过id定位邮箱输入框.输入邮箱
        self.driver.find_element(By.ID, "email").send_keys('432219915@mail.com')
        #通过id定位密码输入框,输入密码
        self.driver.find_element(By.ID, "password1").send_keys('987456.')
        #通过id定位密码输入框,确认输入密码
        self.driver.find_element(By.ID, "confirm_password").send_keys('987456.')
        #通过name定位,确认同意协议并注册
        consent=self.driver.find_element(By.NAME,"Submit").click()


    #退出页面
    def quit(self):
        time.sleep(3)
        self.driver.quit()


#调用
if __name__ == '__main__':
    su= Ecshop()
    su.search()
    su.register()
    su.quit()








